home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / addflo / data1.cab / Program_Executable_Files / AddFlow / Samples / Editor / main.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-05-06  |  16.3 KB  |  557 lines

  1. VERSION 4.00
  2. Begin VB.Form Main 
  3.    Caption         =   "AddFlow Editor"
  4.    ClientHeight    =   4635
  5.    ClientLeft      =   1215
  6.    ClientTop       =   1680
  7.    ClientWidth     =   6225
  8.    FillColor       =   &H0080FFFF&
  9.    BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    Height          =   5325
  20.    Left            =   1155
  21.    LinkTopic       =   "Form1"
  22.    ScaleHeight     =   4635
  23.    ScaleWidth      =   6225
  24.    Top             =   1050
  25.    Width           =   6345
  26.    Begin VB.PictureBox StatusPicture 
  27.       Align           =   2  'Align Bottom
  28.       Height          =   780
  29.       Left            =   0
  30.       ScaleHeight     =   720
  31.       ScaleWidth      =   6165
  32.       TabIndex        =   0
  33.       Top             =   3855
  34.       Width           =   6225
  35.       Begin VB.TextBox TextTag 
  36.          Enabled         =   0   'False
  37.          Height          =   555
  38.          Left            =   570
  39.          MultiLine       =   -1  'True
  40.          ScrollBars      =   2  'Vertical
  41.          TabIndex        =   4
  42.          Top             =   90
  43.          Width           =   1935
  44.       End
  45.       Begin VB.TextBox TextText 
  46.          Enabled         =   0   'False
  47.          Height          =   555
  48.          Left            =   3450
  49.          MultiLine       =   -1  'True
  50.          ScrollBars      =   2  'Vertical
  51.          TabIndex        =   3
  52.          Top             =   90
  53.          Width           =   1935
  54.       End
  55.       Begin VB.Label Label1 
  56.          Caption         =   "Tag:"
  57.          Height          =   255
  58.          Left            =   90
  59.          TabIndex        =   2
  60.          Top             =   90
  61.          Width           =   495
  62.       End
  63.       Begin VB.Label Label2 
  64.          Caption         =   "Text:"
  65.          Height          =   255
  66.          Left            =   2880
  67.          TabIndex        =   1
  68.          Top             =   120
  69.          Width           =   555
  70.       End
  71.    End
  72.    Begin AddFlowLib.AddFlow AddFlow1 
  73.       Height          =   3435
  74.       Left            =   270
  75.       TabIndex        =   5
  76.       Top             =   330
  77.       Width           =   4005
  78.       _Version        =   65536
  79.       _ExtentX        =   7064
  80.       _ExtentY        =   6059
  81.       _StockProps     =   101
  82.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  83.          Name            =   "Arial"
  84.          Size            =   8.25
  85.          Charset         =   0
  86.          Weight          =   400
  87.          Underline       =   0   'False
  88.          Italic          =   0   'False
  89.          Strikethrough   =   0   'False
  90.       EndProperty
  91.       BorderStyle     =   1
  92.       ScrollBars      =   3
  93.       Shape           =   0
  94.       LinkStyle       =   0
  95.       Alignment       =   7
  96.       AutoSize        =   0
  97.       ArrowDst        =   3
  98.       ArrowOrg        =   0
  99.       DrawStyle       =   0
  100.       DrawWidth       =   1,4013e-45
  101.       ReadOnly        =   0   'False
  102.       MultiSel        =   -1  'True
  103.       CanDrawNode     =   -1  'True
  104.       CanDrawLink     =   -1  'True
  105.       CanMoveNode     =   -1  'True
  106.       CanSizeNode     =   -1  'True
  107.       CanStretchLink  =   -1  'True
  108.       CanMultiLink    =   -1  'True
  109.       Transparent     =   0   'False
  110.       ShowGrid        =   0   'False
  111.       Hidden          =   0   'False
  112.       Rigid           =   0   'False
  113.       DisplayHandles  =   -1  'True
  114.       AutoScroll      =   -1  'True
  115.       xGrid           =   7,00649e-45
  116.       yGrid           =   7,00649e-45
  117.       xZoom           =   100
  118.       yZoom           =   100
  119.       FillColor       =   16777215
  120.       DrawColor       =   0
  121.       ForeColor       =   0
  122.       BackPicture     =   "main.frx":0000
  123.    End
  124.    Begin MSComDlg.CommonDialog CMDialog1 
  125.       Left            =   4920
  126.       Top             =   750
  127.       _Version        =   65536
  128.       _ExtentX        =   847
  129.       _ExtentY        =   847
  130.       _StockProps     =   0
  131.    End
  132.    Begin VB.Menu File 
  133.       Caption         =   "&File"
  134.       Begin VB.Menu NewMenu 
  135.          Caption         =   "&New"
  136.       End
  137.       Begin VB.Menu OpenMenu 
  138.          Caption         =   "&Open..."
  139.       End
  140.       Begin VB.Menu SaveMenu 
  141.          Caption         =   "&Save"
  142.       End
  143.       Begin VB.Menu SaveAsMenu 
  144.          Caption         =   "Save &As..."
  145.       End
  146.       Begin VB.Menu SEPARATOR1 
  147.          Caption         =   "-"
  148.       End
  149.       Begin VB.Menu SaveAsMetafileMenu 
  150.          Caption         =   "Save As &Metafile..."
  151.       End
  152.       Begin VB.Menu SEPARATOR7 
  153.          Caption         =   "-"
  154.       End
  155.       Begin VB.Menu PrintFormMenu 
  156.          Caption         =   "&Print Form"
  157.       End
  158.       Begin VB.Menu SEPARATOR2 
  159.          Caption         =   "-"
  160.       End
  161.       Begin VB.Menu ExitMenu 
  162.          Caption         =   "&Exit"
  163.       End
  164.    End
  165.    Begin VB.Menu EditMenu 
  166.       Caption         =   "&Edit"
  167.       Begin VB.Menu CopyMenu 
  168.          Caption         =   "&Copy clipboard"
  169.       End
  170.       Begin VB.Menu DeleteSelectionMenu 
  171.          Caption         =   "&Delete Selection"
  172.       End
  173.       Begin VB.Menu DeleteMarkedMenu 
  174.          Caption         =   "Delete &Marked"
  175.       End
  176.       Begin VB.Menu SEPARATOR3 
  177.          Caption         =   "-"
  178.       End
  179.       Begin VB.Menu SelectAllMenu 
  180.          Caption         =   "Select &All"
  181.       End
  182.       Begin VB.Menu SEPARATOR4 
  183.          Caption         =   "-"
  184.       End
  185.       Begin VB.Menu SelectModeMenu 
  186.          Caption         =   "&Select Mode"
  187.       End
  188.       Begin VB.Menu SEPARATOR5 
  189.          Caption         =   "-"
  190.       End
  191.       Begin VB.Menu ZOrderMenu 
  192.          Caption         =   "&ZOrder"
  193.          Begin VB.Menu ZOrderBackMenu 
  194.             Caption         =   "&Back"
  195.             Enabled         =   0   'False
  196.          End
  197.          Begin VB.Menu ZOrderFrontMenu 
  198.             Caption         =   "&Front"
  199.             Enabled         =   0   'False
  200.          End
  201.       End
  202.       Begin VB.Menu SEPARATOR6 
  203.          Caption         =   "-"
  204.       End
  205.       Begin VB.Menu GroupMenu 
  206.          Caption         =   "&Group"
  207.       End
  208.       Begin VB.Menu UngroupMenu 
  209.          Caption         =   "&Ungroup"
  210.       End
  211.    End
  212.    Begin VB.Menu ViewMenu 
  213.       Caption         =   "&View"
  214.       Begin VB.Menu StatusBarMenu 
  215.          Caption         =   "&StatusBar"
  216.          Checked         =   -1  'True
  217.       End
  218.    End
  219.    Begin VB.Menu DrawMenu 
  220.       Caption         =   "&Draw"
  221.       Begin VB.Menu PropertiesMenu 
  222.          Caption         =   "&Properties..."
  223.       End
  224.    End
  225.    Begin VB.Menu HelpMenu 
  226.       Caption         =   "&?"
  227.       Begin VB.Menu AboutMenu 
  228.          Caption         =   "&About..."
  229.       End
  230.    End
  231. Attribute VB_Name = "Main"
  232. Attribute VB_Creatable = False
  233. Attribute VB_Exposed = False
  234. Option Explicit
  235. Const EXT_NET = "NET"
  236. Const FILTER_NET = "Net Files(*.NET)|*.net|All Files(*.*)|*.*|"
  237. Const EXT_WMF = "WMF"
  238. Const FILTER_WMF = "Wmf Files(*.WMF)|*.wmf|All Files(*.*)|*.*|"
  239. Dim Filename$
  240. Dim wmfFileName$
  241.         
  242. Private Sub AboutMenu_Click()
  243.   MsgBox "AddFlow Editor sample" + Chr(13) + "Copyright 
  244.  1997 Lassalle Technologies"
  245. End Sub
  246. Private Sub CopyMenu_Click()
  247.   AddFlow1.SaveImage 1, 0, ""
  248.   Set AddFlow1.SelectedNode = AddFlow1.PointedLink
  249. End Sub
  250. Private Sub DeleteMarkedMenu_Click()
  251.   AddFlow1.DeleteMarked
  252. End Sub
  253. Private Sub DeleteSelectionMenu_Click()
  254.   AddFlow1.DeleteSel
  255. End Sub
  256. Private Sub ExitMenu_Click()
  257.   End
  258. End Sub
  259. Private Sub AddFlow1_DblClick()
  260.   PropertiesMenu_Click
  261. End Sub
  262. Private Sub AddFlow1_KeyDown(KeyCode As Integer, Shift As Integer)
  263.   Const KEY_DELETE = &H2E
  264.   If KeyCode = KEY_DELETE Then
  265.     DeleteSelectionMenu_Click
  266.   End If
  267. End Sub
  268. Private Sub AddFlow1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  269.   Dim area%
  270.   ' If mouse down don't change the mouse pointer
  271.   Const LEFT_BUTTON = 1
  272.   If (Button And LEFT_BUTTON) > 0 Then
  273.     Exit Sub
  274.   End If
  275.   With AddFlow1
  276.     If .PointedNode Is Nothing And .PointedLink Is Nothing Then
  277.       TextText.Text = ""
  278.       TextTag.Text = ""
  279.     ElseIf .PointedLink Is Nothing Then
  280.       TextText.Text = .PointedNode.Text
  281.       TextTag.Text = .PointedNode.Tag
  282.     Else
  283.       TextText.Text = .PointedLink.Text
  284.       TextTag.Text = .PointedLink.Tag
  285.     End If
  286.     area = .PointedArea
  287.     Select Case area
  288.     Case 0
  289.       .MousePointer = 8
  290.     Case 1
  291.       .MousePointer = 7
  292.     Case 2
  293.       .MousePointer = 6
  294.     Case 3
  295.       .MousePointer = 9
  296.     Case 5
  297.       .MousePointer = 10
  298.     Case Else
  299.       If .SelectMode = True Then
  300.         .MousePointer = 2
  301.       Else
  302.         .MousePointer = 0
  303.       End If
  304.     End Select
  305.   End With
  306. End Sub
  307. Private Sub AddFlow1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  308.   If AddFlow1.SelectedNode Is Nothing And AddFlow1.SelectedLink Is Nothing Then
  309.     ZOrderFrontMenu.Enabled = False
  310.     ZOrderBackMenu.Enabled = False
  311.   Else
  312.     ZOrderFrontMenu.Enabled = True
  313.     ZOrderBackMenu.Enabled = True
  314.   End If
  315. End Sub
  316. Private Sub Form_Load()
  317.   AddFlow1.Left = 0
  318.   AddFlow1.Top = 0
  319. End Sub
  320. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  321.   QueryUnload (Cancel)
  322. End Sub
  323. Private Sub Form_Resize()
  324.   If WindowState <> 1 And ScaleHeight <> 0 Then
  325.     If StatusPicture.Visible Then
  326.       AddFlow1.Height = ScaleHeight - StatusPicture.Height
  327.       StatusPicture.Top = AddFlow1.Height
  328.     Else
  329.       AddFlow1.Height = ScaleHeight
  330.     End If
  331.     AddFlow1.Width = ScaleWidth
  332.   End If
  333. End Sub
  334. Private Function GetFileName(Ext As String, Filter As String) As String
  335.   Const OFN_OVERWRITEPROMPT = &H2&
  336.   Const OFN_SHOWHELP = &H10&
  337.   Const OFN_CREATEPROMPT = &H2000&
  338.   'Display file open dialog
  339.   CMDialog1.DefaultExt = "NET"
  340.   CMDialog1.Filter = Filter
  341.   CMDialog1.Flags = OFN_OVERWRITEPROMPT Or OFN_SHOWHELP Or OFN_CREATEPROMPT
  342.   CMDialog1.Action = 1
  343.   'Select a file and open it
  344.   GetFileName = CMDialog1.Filename
  345. End Function
  346. Private Sub GroupMenu_Click()
  347.   Dim LeftMin As Single, TopMin As Single
  348.   Dim RightMax As Single, BottomMax As Single
  349.   Dim nodx As afNode, owner As afNode, lnkx As afLink
  350.   Dim First As Boolean
  351.   With AddFlow1
  352.     First = True
  353.     For Each nodx In .Nodes
  354.       If nodx.Selected Then
  355.         If First = True Then
  356.           First = False
  357.           LeftMin = nodx.Left
  358.           TopMin = nodx.Top
  359.           RightMax = nodx.Left + nodx.Width
  360.           BottomMax = nodx.Top + nodx.Height
  361.         Else
  362.           If nodx.Left < LeftMin Then LeftMin = nodx.Left
  363.           If nodx.Top < TopMin Then TopMin = nodx.Top
  364.           If nodx.Left + nodx.Width > RightMax Then
  365.             RightMax = nodx.Left + nodx.Width
  366.           End If
  367.           If nodx.Top + nodx.Height > BottomMax Then
  368.             BottomMax = nodx.Top + nodx.Height
  369.           End If
  370.         End If
  371.       End If
  372.     Next
  373.     If Not First Then
  374.       Set owner = .Nodes.Add(LeftMin, TopMin, RightMax - LeftMin, BottomMax - TopMin)
  375.       owner.Hidden = True      'Invisible
  376.       owner.Shape = afRectangle
  377.       owner.Transparent = True 'Transparent
  378.       For Each nodx In .Nodes
  379.         If nodx.Selected Then
  380.           Set lnkx = owner.OutLinks.Add(nodx)
  381.           lnkx.Rigid = True
  382.           lnkx.Hidden = True
  383.           lnkx.Selectable = False
  384.           nodx.Selectable = False
  385.         End If
  386.       Next
  387.       Set .SelectedNode = owner
  388.     End If
  389.   End With
  390. End Sub
  391. Private Sub NewMenu_Click()
  392.   Dim Cancel%
  393.   Call QueryUnload(Cancel)
  394.   If Cancel = False Then
  395.     AddFlow1.Nodes.Clear
  396.     AddFlow1.SetChangedFlag False
  397.   End If
  398. End Sub
  399. Private Sub OpenMenu_Click()
  400.   Dim Cancel%
  401.   Call QueryUnload(Cancel)
  402.   If Cancel = False Then
  403.     Filename = GetFileName(EXT_NET, FILTER_NET)
  404.     If Filename <> "" Then
  405.       AddFlow1.Nodes.Clear
  406.       MousePointer = 11
  407.       OpenEasyNetFile AddFlow1, Filename
  408.       MousePointer = 0
  409.       AddFlow1.SetChangedFlag False
  410.     End If
  411.   End If
  412. End Sub
  413. Private Sub QueryUnload(Cancel As Integer)
  414.   Dim Msg$, NL$, Response%
  415.   If AddFlow1.IsChanged Then
  416.     Cancel = False
  417.     ' Message box
  418.     NL = Chr$(10) & Chr$(13)
  419.     If Filename <> "" Then
  420.       Msg = "The diagram in [" & Filename & "] has changed."
  421.       Msg = Msg & NL
  422.     End If
  423.     Msg = Msg & "Do you want to save the changes?"
  424.     Response = MsgBox(Msg, 51, App.Title)
  425.     Select Case Response
  426.     ' Yes
  427.     Case 6
  428.       If Filename = "" Then
  429.         'Get the filename to save the file
  430.         Filename = GetFileName(EXT_NET, FILTER_NET)
  431.         'If the user did not specify a file name,
  432.         'cancel the unload; otherwise, save it.
  433.         If Filename = "" Then
  434.           Cancel = True
  435.         Else
  436.           SaveEasyNetFile AddFlow1, Filename
  437.         End If
  438.       Else
  439.         SaveEasyNetFile AddFlow1, Filename
  440.       End If
  441.     ' No
  442.     Case 7
  443.     ' Cancel
  444.     Case 2
  445.       Cancel = True
  446.     End Select
  447.   End If
  448. End Sub
  449. Private Sub PrintFormMenu_Click()
  450.   PrintForm
  451. End Sub
  452. Private Sub PropertiesMenu_Click()
  453.   ItemProp.Show 1
  454. End Sub
  455. Private Sub SaveAsMenu_Click()
  456.   Const OFN_OVERWRITEPROMPT = &H2&
  457.   Const OFN_SHOWHELP = &H10&
  458.   Const OFN_CREATEPROMPT = &H2000&
  459.   'Display file save dialog
  460.   CMDialog1.DefaultExt = EXT_NET
  461.   CMDialog1.Filter = FILTER_NET
  462.   CMDialog1.Flags = OFN_OVERWRITEPROMPT Or OFN_SHOWHELP Or OFN_CREATEPROMPT
  463.   CMDialog1.Filename = Filename
  464.   CMDialog1.DialogTitle = "Save As..."
  465.   CMDialog1.Action = 2
  466.   'Select a file
  467.   Filename = CMDialog1.Filename
  468.   If Filename <> "" Then
  469.     MousePointer = 11
  470.     SaveEasyNetFile AddFlow1, Filename
  471.     MousePointer = 0
  472.     AddFlow1.SetChangedFlag False
  473.   End If
  474. End Sub
  475. Private Sub SaveAsMetafileMenu_Click()
  476.   Const OFN_OVERWRITEPROMPT = &H2&
  477.   Const OFN_SHOWHELP = &H10&
  478.   Const OFN_CREATEPROMPT = &H2000&
  479.   ' Display file save dialog
  480.   With CMDialog1
  481.     .DefaultExt = EXT_WMF
  482.     .Filter = FILTER_WMF
  483.     .Flags = OFN_OVERWRITEPROMPT Or OFN_SHOWHELP Or OFN_CREATEPROMPT
  484.     .Filename = wmfFileName
  485.     .DialogTitle = "Save As Metafile..."
  486.     .Action = 2
  487.   End With
  488.   ' Select a file
  489.   wmfFileName = CMDialog1.Filename
  490.   If wmfFileName <> "" Then
  491.     MousePointer = 11
  492.     AddFlow1.SaveImage 0, 0, wmfFileName
  493.     MousePointer = 0
  494.   End If
  495. End Sub
  496. Private Sub SaveMenu_Click()
  497.   If AddFlow1.IsChanged() = True Then
  498.     If Len(Filename) <> 0 Then
  499.       MousePointer = 11
  500.       SaveEasyNetFile AddFlow1, Filename
  501.       MousePointer = 0
  502.       AddFlow1.SetChangedFlag False
  503.     Else
  504.       SaveAsMenu_Click
  505.     End If
  506.   End If
  507. End Sub
  508. Private Sub SelectAllMenu_Click()
  509.   AddFlow1.SelectAll
  510. End Sub
  511. Private Sub SelectModeMenu_Click()
  512.   AddFlow1.SelectMode = Not AddFlow1.SelectMode
  513.   If AddFlow1.SelectMode = True Then
  514.     SelectModeMenu.Checked = True
  515.     AddFlow1.MousePointer = 2
  516.   Else
  517.     SelectModeMenu.Checked = False
  518.     AddFlow1.MousePointer = 0
  519.   End If
  520. End Sub
  521. Private Sub StatusBarMenu_Click()
  522.   StatusPicture.Visible = Not StatusPicture.Visible
  523.   StatusBarMenu.Checked = StatusPicture.Visible
  524.   Form_Resize
  525. End Sub
  526. Private Sub UngroupMenu_Click()
  527.   If AddFlow1.SelectedNode Is Nothing Then
  528.     ' Nothing to do
  529.   Else
  530.     Dim lnkx As afLink
  531.     For Each lnkx In AddFlow1.SelectedNode.OutLinks
  532.       If lnkx.Selectable = False Then
  533.         lnkx.Dst.Selectable = True
  534.       End If
  535.     Next
  536.     AddFlow1.Nodes.Remove AddFlow1.SelectedNode
  537.   End If
  538. End Sub
  539. Private Sub ZOrderBackMenu_Click()
  540.   If AddFlow1.SelectedNode Is Nothing And AddFlow1.SelectedLink Is Nothing Then
  541.     ' Nothing to do
  542.   ElseIf AddFlow1.SelectedNode Is Nothing Then
  543.     AddFlow1.SelectedLink.ZOrder = True
  544.   Else
  545.     AddFlow1.SelectedNode.ZOrder = True
  546.   End If
  547. End Sub
  548. Private Sub ZOrderFrontMenu_Click()
  549.   If AddFlow1.SelectedNode Is Nothing And AddFlow1.SelectedLink Is Nothing Then
  550.     ' Nothing to do
  551.   ElseIf AddFlow1.SelectedNode Is Nothing Then
  552.     AddFlow1.SelectedLink.ZOrder = False
  553.   Else
  554.     AddFlow1.SelectedNode.ZOrder = False
  555.   End If
  556. End Sub
  557.